/**
 * 				Mochito.java
 *				------------
 *		
 *   Author:	bin04017@gmail.com
 *	 Created:	13.12.2006
 *	 Project:	MP3-Sync (Mochito)
 *	 Package:	mochito
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 */
package mochito;

import gui.IpInput;
import gui.MochitoClientGui;
import gui.MochitoServerGui;

/**
 * @author bin04017
 *
 */
public class Mochito {

	private String host = null;
		
	private MochitoServerGui serverGUI = null;
	
	private MochitoClientGui clientGUI = null;
	
	public Mochito (MochitoType mochitoType, String host){
		this.host = host;
		if(MochitoType.ServerGUI == mochitoType){
			serverGUI = new MochitoServerGui(host);
			serverGUI.setVisible(true);
		} else if(MochitoType.ClientGUI == mochitoType){
			IpInput ipGui = null;
			if(host == null){
				ipGui = new IpInput();
				ipGui.setVisible(true);
			}
			while(ipGui != null && ipGui.getIp() == null){
				try {
					Thread.sleep(1000);
				} catch (InterruptedException e) {
				}
			}
			host = ipGui.getIp();
			clientGUI = new MochitoClientGui(host);
			clientGUI.setVisible(true);
		}
	}

	public MochitoClientGui getClientGUI() {
		return clientGUI;
	}

	public String getHost() {
		return host;
	}

	public MochitoServerGui getServerGUI() {
		return serverGUI;
	}
}
